package com.medical.admin.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.medical.admin.sys.common.dto.PermissionDto;
import com.medical.admin.sys.entity.Permission;
import com.medical.admin.sys.mapper.PermissionMapper;
import com.medical.admin.sys.service.PermissionService;
import com.qf.medical.utils.BeanConvertUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/*
 * @Date : 2024/4/26 19:03
 * @Created by Lang
 * @ProjectName : medical-appointment-registration
 */
@Service
public class PermissionServiceImpl implements PermissionService {
    @Resource
    private PermissionMapper permissionMapper;

    @Override
    public List<PermissionDto> list() {
        QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
        LambdaQueryWrapper<Permission> eq = queryWrapper.lambda().select(Permission::getPermissionId, Permission::getPermissionName, Permission::getPermissionDescription).eq(Permission::getPermissionStatus, 1);
        List<Permission> permissions = permissionMapper.selectList(eq);
        return  BeanConvertUtils.convertListTo(permissions, PermissionDto::new);
    }
}
